#!/bin/bash

echo "=== 合理用药审查系统编译验证 ==="
echo "项目路径: $(pwd)"
echo "Java版本: $(java -version 2>&1 | head -1)"
echo

echo "=== 检查Java源文件语法 ==="
find src/main/java -name "*.java" | wc -l | xargs echo "Java文件总数:"

echo
echo "=== 检查是否有明显的语法错误 ==="
# 检查常见的语法问题
echo "检查泛型语法..."
if grep -r "&lt;\|&gt;" src/main/java; then
    echo "❌ 发现HTML转义字符，需要修复"
else
    echo "✅ 泛型语法正常"
fi

echo
echo "检查包声明..."
find src/main/java -name "*.java" -exec head -1 {} + | grep -v "^package" | wc -l | xargs echo "可能的包声明问题:"

echo
echo "检查类定义..."
grep -r "^public class\|^public interface" src/main/java | wc -l | xargs echo "类和接口定义数量:"

echo
echo "=== 检查资源文件 ==="
ls -la src/main/resources/
echo

echo "=== 项目结构总结 ==="
echo "实体类 (Entity):"
ls src/main/java/com/kh/rationaldrugreview/entity/ | wc -l | xargs echo "  数量:"

echo "数据访问层 (Mapper):"
ls src/main/java/com/kh/rationaldrugreview/mapper/ 2>/dev/null | wc -l | xargs echo "  数量:"

echo "服务层 (Service):"
ls src/main/java/com/kh/rationaldrugreview/service/ 2>/dev/null | wc -l | xargs echo "  数量:"

echo "控制层 (Controller):"
ls src/main/java/com/kh/rationaldrugreview/controller/ 2>/dev/null | wc -l | xargs echo "  数量:"

echo "Neo4j相关:"
find src/main/java/com/kh/rationaldrugreview/neo4j -name "*.java" 2>/dev/null | wc -l | xargs echo "  数量:"

echo
echo "=== 编译验证完成 ==="